import Vue from 'vue';
import Vuex from 'vuex';

Vue.use(Vuex);
// 登录验证
export default new Vuex.Store({
    state: {
        // ...scrmStore,
        userInfo: {},
        token: ""
    },
    mutations: {
        // 登录
        setUserInfo(state, userInfo) {
            state.userInfo = userInfo;
            localStorage.setItem("userInfo", JSON.stringify(userInfo));
        },
        setToken(state, token) {
            state.token = token;
            localStorage.setItem("token", token);
        },
        // 退出
        logout(state, user) {
            state.user = "";
            localStorage.setItem("userInfo", "");
        },
    },
    getters: {
        getToken: (state) => {
            state.token = localStorage.getItem('token');
            return state.token;
        },
        getUserInfo: (state) => {
            state.userInfo = JSON.parse(localStorage.getItem('userInfo'));
            return state.userInfo;
        }
    }
})
// let scrmStore = {

// }

// export { scrmStore }